<?php
require_once 'mysql/mysql.php';
require_once 'redis/Redis.class.php';
if(!empty($_POST['username']) && !empty($_POST['password']))
{
    $username = trim($_POST['username']);
    
    $password = trim($_POST['password']);
    
    $login_sql = "select * from admin where adm_username = '".$username."' and adm_password = '".$password."'";
    
    $db = new Mysqlconnect();
    
    $login_result = $db->getRow($login_sql);
    
    if(!empty($login_result) && $login_result['adm_password'] == $password)
    {
        $user_id = $login_result["id"];
        
        setcookie("login_id",base64_encode($user_id)); //设置cookie值
        
        $redis_model = new Redis_model();
        $redis_model->SET(base64_encode($user_id),$user_id);
        
        //代表登录成功
        header("Location:index.php");
        exit;
        
    }else
    {
        header("Location:login.php");
        exit;
    }    
}else
{
    header("Location:login.php");
    exit;
}
?>